﻿<script src="../../Content/Paging/Pages.js" type="text/javascript"></script>
<link href="../../Content/Paging/Pages.css" rel="stylesheet" type="text/css" />
@*@model IEnumerable<DAL.Post_ResultSearch_View>*@
@model IEnumerable<HomeStayWebCP.Models.BusinessObject.ResultObject>
@{
    if (Model.Count() == 0)
    {
        <p style="font-size: 18px;font-weight: bold;color: #1D95CB;float: left;margin:20px;"> No Results Found!You can choose another place for search</p>
    }
    else
    {
  <ul id="results">
  
    @foreach (var item in Model)
    {
        var price = 0;
       
        if (ViewBag.PriceType > 0)
        {
            
            if (ViewBag.PriceType == 1)
            {
                price = Convert.ToInt32(item.PricePerDay);
            }

            if (ViewBag.PriceType == 2)
            {
                price = Convert.ToInt32(item.PricePerWeek);
            }
            if (ViewBag.PriceType == 3)
            {
                price = Convert.ToInt32(item.PricePerMonth);
            }

        }
        else
        {
            if (item.PricePerDay > 0)
            {
                price = Convert.ToInt32(item.PricePerDay);
            }
            else if (item.PricePerWeek > 0)
            {
                price = Convert.ToInt32(item.PricePerWeek) / 7;
            }
            else
            {
                price = Convert.ToInt32(item.PricePerMonth) / 30;
            }
        }


        if (item.TimeCreated.Day==DateTime.Now.Day && item.TimeCreated.Month == DateTime.Now.Month && item.TimeCreated.Year == DateTime.Now.Year)
        {
                <div style="position: absolute; z-index: 1"><img alt ="#" src="../../Content/images/icons/new.png" width="40px" height="40px"/></div>
        }
        <li class="result" style="padding-bottom: 0px;"id="@price" >
               
            <div class="post_image_small">
                <a href="/Posts/ViewPost?postID=@item.PostID" title="@item.Title">
                    <img src="../../Content/images/PostImage/@item.AvatarPost" alt="@item.Title"/>
                </a>
            </div>
            <div class="user_thumb">
                <a href="#" title="@item.Username">
                    <img  src="../../Content/images/AvatarUser/@item.AvatarUser" width="36px" height="36px" alt="NgocHtn"/>
                </a>
            </div>
            <h3 class="post_title"  style="font-weight: bold">
                <a href="/Posts/ViewPost?postID=@item.PostID">@Html.DisplayFor(modelItem => item.Title)</a> 
            </h3>
            <div class="post_price">
                <div class="price">
                    @{
    if (ViewBag.PriceType > 0)
    {
        if (ViewBag.PriceType == 1)
        {
                                @Html.DisplayFor(modelItem => item.PricePerDay)
        }
        if (ViewBag.PriceType == 2)
        {
                                @Html.DisplayFor(modelItem => item.PricePerWeek)
        }
        if (ViewBag.PriceType == 3)
        {
                                @Html.DisplayFor(modelItem => item.PricePerMonth)
        }

    }
    else
    {
        if (item.PricePerDay > 0)
        {

                                @Html.DisplayFor(modelItem => item.PricePerDay)
        }
        else
        {
            if (item.PricePerWeek > 0)
            {
                                    @Html.DisplayFor(modelItem => item.PricePerWeek)
            }
            else
            {
                                    @Html.DisplayFor(modelItem => item.PricePerMonth)
            }
        }
    }
                        
                    }
                    <sup>$</sup>
                </div>
                @{
    if (ViewBag.PriceType > 0)
    {
        if (ViewBag.PriceType == 1)
        {
                            <div class="perdate">
                             perdate
                         </div>
        }
        if (ViewBag.PriceType == 2)
        {
                            <div class="perdate">
                                 perweek
                             </div>
        }
        if (ViewBag.PriceType == 3)
        {
                           <div class="perdate">
                                 permonth
                             </div>
        }

    }
    else
    {
        if (item.PricePerDay > 0)
        {
                         <div class="perdate">
                             perdate
                         </div>

        }
        else
        {
            if (item.PricePerWeek > 0)
            {
                             <div class="perdate">
                                 perweek
                             </div>
            }
            else
            {
                             <div class="perdate">
                                 permonth
                             </div>
            }
        }
    }
                   
                }
                @if (item.IsAvailable)
                {
                               <div style="margin-top: 50px;margin-left: 80px;background: yellowGreen;font-weight: 900;font-size: 15px;">
                                   <p style="margin-left: 5px;color: white">Available</p>
                               </div>
                }
                else
                {
                               <div style="margin-top: 50px;margin-left: 57px;background: orangered;font-weight: 900;font-size: 15px;">
                                   <p  style="margin-left: 5px;color: white">Not Available</p>
                               </div>
                }
                       </div>
           
            <div class="post_address">@item.AddressHouse</div>

        @{
                if (item.like_count > 0)
                {
                <img src="../../Content/images/LikeButton.png" style="float: left;margin-left: -50px;width: 30px;height: 30px;margin-top: 6px" />
                <p style=" margin-top: 14px; padding: 0px!important;float:left;">@item.like_count liked</p>
                }
        }
        </li>
       
    }
</ul>
 <div id="load_page" style="float: right">
         </div>
    }
}
@if (ViewBag.ProvinceSearch!=null)
{
    <script type="text/javascript">
        $(function() {
            $('#province').load($('#ddlprovince').val(@ViewBag.ProvinceSearch));
             $.ajax({
                        url: "/Regions/GetDistrictProvince",
                        type: 'POST',
                        asyn: false,
                        data: { province: @ViewBag.ProvinceSearch, district: @ViewBag.DistrictSearch  },
                        success: function (response) {
                            $("#ddldistrict").replaceWith(response);

                        },
                        error: function (xhr) {
                            alert("Something went wrong, please try again");
                        }

                    });
        
           $('#ddldistrict').val(488);
            
        });
    </script>
    
}
  <script type="text/javascript" language="javascript">
      $(document).ready(function() {
          pages(@ViewBag.page, @ViewBag.page, @ViewBag.count);
          $("#ddlprice").val(-1);
         
      });
     
  </script>